import { Controller, Get, Inject } from '@nestjs/common';
import { NacosService } from './nacos.service';

@Controller('nacos')
export class NacosController {
  constructor(private readonly etcdTestService: NacosService) {}

  @Inject(NacosService)
  private nacosService: NacosService;

  @Get('register')
  async register() {
    const aaaServiceName = 'aaaService';
    const instance1 = {
      ip: '127.0.0.1',
      port: 8080,
    };

    this.nacosService.register(aaaServiceName, instance1);

    const instance2 = {
      ip: '127.0.0.1',
      port: 8081,
    };

    this.nacosService.register(aaaServiceName, instance2);
  }
  @Get('deregister')
  async deregister() {
    const aaaServiceName = 'aaaService';
    const instance1 = {
      ip: '127.0.0.1',
      port: 8080,
    };

    this.nacosService.deregister(aaaServiceName, instance1);

    
    const instance2 = {
      ip: '127.0.0.1',
      port: 8081,
    };

    this.nacosService.deregister(aaaServiceName, instance2);
  }
}
